When something moves back and forth, it shifts repeatedly from one place to another, either front to back or side to side. When your cat's tail moves back and forth, he's not in the mood for belly rubs.
If you live in New York and work in Alaska, you'll have to fly back and forth. And if you're shy, you may just sway back and forth to the music when you're forced to dance at your cousin's wedding. This adverbial phrase is good for describing any kind of to and fro movement. With hyphens, back-and-forth is an exchange of ideas: "The back-and-forth between the director and the audience was the best part of the film screening."